package ysq.xyg.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author yu sheng qiang
 * @create 2017-03-27 16:43
 **/
public class ProProperties {
    private static final String resource = "/pro.properties";
    private Properties prop = new Properties();
    public static ProProperties instance = new ProProperties();

    public static ProProperties getInstance() {
        return instance;
    };

    private ProProperties() {
        String stripped = resource.startsWith("/") ? resource.substring(1) : resource;
        InputStream stream = null;
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null) {
            stream = classLoader.getResourceAsStream(stripped);
        }
        if (stream == null) {
            stream = ProProperties.class.getResourceAsStream(resource);
        }
        if (stream == null) {
            stream = ProProperties.class.getClassLoader().getResourceAsStream(stripped);
        }
        if (stream != null) {
            try {
                prop.load(stream);
            } catch (IOException e) {
                // TODO
            }
        }
    }
    

    //图片路径
    public String getPictureURL() {
        return prop.getProperty("pictureURL");
    }

    //保存路径
    public String getBaseUploadURL() {
        return prop.getProperty("baseUploadURL");
    }

    //微信oauth获取openid通用接口
    public String getWxOauthAcceptOpenidURL() {
        return prop.getProperty("wxOauthAcceptOpenidURL");
    }
    //#微信oauth获取通用接口
    public String getWxOauthURL(String state) {
        return prop.getProperty("wxOauthURL")+state;
    }
    //微信设备详情接口
    public String getWxProductDescURL(String openid,String id) {
        return prop.getProperty("wxProductDesc").replace("OPENID",openid).replace("ID",id);
    }
    //微信模板消息id
    public String getWxTempletIdURL() {
        return prop.getProperty("wxTempletId");
    }
    //微信oauth跳转到首页面接口
    public String getWxOauthRredirectIndexURL(String memberId) {
        return prop.getProperty("wxOauthRredirectIndexURL")+memberId;
    }
    //微信oauth跳转到添加产品页面接口
    public String getWxOauthRredirectAddURL(String deviceId,String openid,String type) {
        return prop.getProperty("wxOauthRredirectAddURL").replace("DEVICEID",deviceId).replace("OPENID",openid).replace("TYPE",type);
    }

    //微信oauth跳转到我的页面接口
    public String getWxPayRequestURL(){
        return prop.getProperty("wxPayRequestURL");
    }

    //微信分享标题
    public String getfxTitle( ){
        return prop.getProperty("fxTitle");
    }
    //微信分享图片地址
    public String getfxImgUrl(){
        return prop.getProperty("fxImgUrl");
    }
    //微信分享描述
    public String getfxDesc(){
        return prop.getProperty("fxDesc");
    }
    //微信分享链接
    public String getfxUrl(){
        return prop.getProperty("fxUrl");
    }
    //秘钥地址
    public String getKeyAddress(){
        return prop.getProperty("keyAddress");
    }

    /**
     * 短信宝接口
     */
    public String getSmsUrl(){
        return prop.getProperty("smsUrl");
    }
    public String getSmsQueryUrl(){
        return prop.getProperty("smsQueryUrl");
    }
    public String getSmsUserName(){
        return prop.getProperty("smsUserName");
    }
    public String getSmsPassword(){
        return prop.getProperty("smsPassword");
    }

    /**
     * 容联云
     */
    public String getCloopenAccountSid (){
        return prop.getProperty("cloopenAccountSid");
    }
    public String getCloopenAuthToken (){
        return prop.getProperty("cloopenAuthToken");
    }
    public String getCloopenAppId (){
        return prop.getProperty("cloopenAppId");
    }

    /**
     * 云之讯短信
     */
    public String getUcpaasRestServer(){
        return prop.getProperty("ucpaasRestServer");
    }
    public String getUcpaasAppId(){
        return prop.getProperty("ucpaasAppId");
    }
    public String getUcpaasAccountSid(){
        return prop.getProperty("ucpaasAccountSid");
    }
    public String getUcpaasAuthToken(){
        return prop.getProperty("ucpaasAuthToken");
    }
    public String getUcpaasTemplateId(){
        return prop.getProperty("ucpaasTemplateId");
    }
    public static void main(String[] str){

    }
}
